home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Circle_pattern.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  6.0 KB  |  214 lines

  1. /*
  2. ** $VER: Circle_pattern.ieb 1.1, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten 
  5. ** 24/1 1997 Stockholm/Sweden
  6. **
  7. ** Place PRIMARY images in a circular pattern on SECONDARY image.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31. /* F = Current image number                                            */
  32.  
  33. get_info:
  34.   back = 'OK S2 F'
  35. return back
  36.  
  37. /* Required "Get_config" procedure  ---------------------------------- */
  38.  
  39. get_config:
  40.   parse arg '"'command'"'
  41.   
  42.   Xoff=128 ; Yoff=128 ; Angle=0 ; Radius=64
  43.   
  44.   if command ~= '' then parse var command Xoff Yoff '#'Cfunk '#'Objects Angle Radius '#'Rotate
  45.  
  46.   'IE_TO_FRONT'
  47.  
  48.   form = 'FORM "Circle Pattern" " OK | Cancel "',
  49.   ' INTEGER,"X offset",0,4096,'Xoff',SLIDER',
  50.   ' INTEGER,"Y offset",0,4096,'Yoff',SLIDER',
  51.   ' INTEGER,"Rotation angle",-3600,3600,'Angle',SLIDER',
  52.   ' INTEGER,"Pattern radius",0,4096,'Radius',SLIDER'
  53.  
  54.   if command = '' then do
  55.     form = form||' CYCLE,"Composite method","Add|Difference|Max|Min|Multiply|Subtract",0',
  56.     ' INTEGER,"Number of objects",1,360,5,SLIDER',
  57.     ' CHECKBOX,"Rotate objects within circle?",1'
  58.     
  59.     form
  60.     parse var result ok Xoff Yoff Angle Radius CFunk Objects Rotate
  61.     if ok = 0 then return '<ERROR>'
  62.  
  63.     select
  64.       when CFunk = 0 then CFunk = 'ADD'
  65.       when CFunk = 1 then CFunk = 'DIFFERENCE'
  66.       when CFunk = 2 then CFunk = 'MAX'
  67.       when CFunk = 3 then CFunk = 'MIN'
  68.       when CFunk = 4 then CFunk = 'MULTIPLY'
  69.       when CFunk = 5 then CFunk = 'SUBTRACT'
  70.     end
  71.   end
  72.   else do
  73.     form
  74.     parse var result ok Xoff Yoff Angle Radius
  75.     if ok = 0 then return '<ERROR>'
  76.  
  77.     CFunk = 'none'
  78.     Objects = 'none'
  79.     Rotate = 'none'
  80.   end
  81.  
  82.   back = Xoff Yoff '#'Cfunk '#'Objects Angle Radius '#'Rotate
  83. return back
  84.  
  85. /* Required "Process_image" procedure  ------------------------------- */
  86.  
  87. process_image:
  88.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'sec_image'"' '"'frame':'num_frames'"'
  89.   parse var options Xoff Yoff '#'Cfunk '#'Objects Angle Radius '#'Rotate
  90.  
  91.   if add_mathlib() = '<ERROR>' then return '<ERROR>'
  92.  
  93.   'OPEN' '"'src_image'"' '24'
  94.   if (RC ~= 0) then do
  95.     'IE_TO_FRONT'
  96.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  97.     return '<ERROR>'
  98.   end
  99.   else LoadImage = result
  100.  
  101.   'OPEN' '"'sec_image'"' '24'
  102.   if (RC ~= 0) then do
  103.     'IE_TO_FRONT'
  104.     'REQUEST' '"Failed to load SECONDARY image:' d2c(10)||sec_image'"' '" OK "'
  105.     return '<ERROR>'
  106.   end
  107.   else SecImage = result
  108.  
  109.   do until ((Angle < 360)&(Angle >= 0))
  110.     if Angle > 359 then Angle = Angle - 360
  111.     if Angle < 0 then Angle = Angle + 360
  112.   end
  113.   
  114.   'PROJECT_INFO' LoadImage 'WIDTH'  /* PRI image width */
  115.   PIW = RESULT
  116.   'PROJECT_INFO' LoadImage 'HEIGHT' /* PRI image height */
  117.   PIH = RESULT
  118.  
  119.   'PROJECT_INFO' SecImage 'WIDTH'   /* SEC image width */
  120.   SIW = RESULT                      
  121.   'PROJECT_INFO' SecImage 'HEIGHT'  /* SEC image height */
  122.   SIH = RESULT
  123.  
  124.   do i = 1 to Objects
  125.  
  126.     ObjAngle = Angle+((i-1)*360/Objects)
  127.  
  128.     NewXoff = Xoff + trunc( cos(((ObjAngle)/360*6.2831853)+1.57079633)*Radius )
  129.     NewYoff = Yoff + trunc( sin(((ObjAngle)/360*6.2831853)+1.57079633)*Radius )
  130.  
  131.     ObjAngle = trunc( ObjAngle )
  132.     
  133.     if (Rotate = 1)&(ObjAngle ~= 0) then do
  134.       'ROTATE' LoadImage ObjAngle CalcType  /* Rotate image */
  135.       NewLoadImage = result
  136.     end /* do rotate within */
  137.     else NewLoadImage = LoadImage
  138.  
  139.     'PROJECT_INFO' NewLoadImage 'WIDTH'  /* NewPRI image width */
  140.     NewPIW = Result
  141.     'PROJECT_INFO' NewLoadImage 'HEIGHT' /* NewPRI image height */
  142.     NewPIH = Result
  143.  
  144.     NewXoff = NewXoff - trunc( NewPIW/2 )
  145.     NewYoff = NewYoff - trunc( NewPIH/2 )
  146.         
  147.     if NewXoff < -NewPIW then NewXoff = -NewPIW
  148.     if NewXoff > SIW then NewXoff = SIW
  149.     if NewYoff < -NewPIH then NewYoff = -NewPIH
  150.     if NewYoff > SIH then NewYoff = SIH
  151.  
  152.     'MARK' NewLoadImage 'PRIMARY'
  153.     'MARK' SecImage 'SECONDARY'
  154.  
  155.     'COMPOSITE' NewXoff NewYoff CFunk
  156.     NewSecImage = Result
  157.     'CLOSE' SecImage
  158.     SecImage = NewSecImage
  159.     
  160.     if (Rotate = 1)&(ObjAngle ~= 0) then 'CLOSE' NewLoadImage
  161.  
  162.   end /* Objects loop */
  163.  
  164.   'CLOSE' LoadImage
  165.   OutputImage = SecImage
  166.  
  167.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  168.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  169.   if (RC ~= 0) then do
  170.     'IE_TO_FRONT'
  171.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  172.     return '<ERROR>'
  173.   end
  174.   'CLOSE' OutputImage
  175.  
  176.   back = 'OK'
  177. return back
  178.  
  179. /* Internal procedures  ---------------------------------------------- */
  180.  
  181. add_mathlib:
  182.   if ~show(L,'rexxmathlib.library') then do
  183.     if exists('LIBS:rexxmathlib.library') then do
  184.       if ~addlib('rexxmathlib.library',0,-30,0) then do
  185.         'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "'
  186.         return '<ERROR>'
  187.       end
  188.     end /* lib found on disk */
  189.     else do
  190.       'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "'
  191.       return '<ERROR>'
  192.     end
  193.   end /* lib exists in mem */
  194. return 'OK'
  195.  
  196. /*******************************************************************/
  197. /* This is where control goes when an error code is returned by IE */
  198. /* It puts up a message saying what happened and on which line     */
  199. /*******************************************************************/
  200.  
  201. error:
  202. if RC=5 then do
  203.     IE_TO_FRONT
  204.     LAST_ERROR
  205.     'REQUEST "'||RESULT||'"'
  206. end
  207. else do
  208.     IE_TO_FRONT
  209.     LAST_ERROR
  210.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  211. end
  212.  
  213. return '<ERROR>'
  214.